<!DOCTYPE html>
<svg></svg>
<script>
var svg = document.querySelector("svg");
var g = document.createElementNS('http://www.w3.org/2000/svg', 'g');
var rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
var attrs = { x: 100, y:100, width: 100, height: 100, fill: 'green' };
for (var k in attrs)
  rect.setAttribute(k, attrs[k]);

var matrix = svg.createSVGMatrix().translate(-100, -100);
g.transform.baseVal.appendItem(svg.createSVGTransformFromMatrix(matrix));

svg.appendChild(g).appendChild(rect);
</script>
